package com.csu.cphone.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csu.cphone.dao.RecycleProblemSelectMapper;
import com.csu.cphone.pojo.RecycleProblemSelectPojo;
import com.csu.cphone.service.RecycleProblemSelectService;

/**
 * @项目名称：cphone
 * @类名称：RecycleProblemSelectServiceImpl
 * @类描述：
 * @创建人：Tangc
 * @创建时间：2017年12月7日 下午10:16:47
 * @company:
 */
@Service
public class RecycleProblemSelectServiceImpl implements RecycleProblemSelectService
{

    @Autowired
    private RecycleProblemSelectMapper problemSelectMapper;

    /**
     * @see com.csu.cphone.service.RecycleProblemSelectService#update(com.csu.cphone.pojo.RecycleProblemSelectPojo)
     */
    @Override
    public Integer update(RecycleProblemSelectPojo selectPojo)
    {
        return problemSelectMapper.update(selectPojo);
    }

    /**
     * @see com.csu.cphone.service.RecycleProblemSelectService#queryById(java.lang.Integer)
     */
    @Override
    public RecycleProblemSelectPojo queryById(Integer recycleProblemSelectId)
    {
        return problemSelectMapper.selectById(recycleProblemSelectId);
    }

    /**
     * @see com.csu.cphone.service.RecycleProblemSelectService#count()
     */
    @Override
    public Integer count(Integer problemId)
    {
        if (problemId != null && problemId == 0)
        {
            problemId = null;
        }
        return problemSelectMapper.count(problemId);
    }

    /**
     * @see com.csu.cphone.service.RecycleProblemSelectService#queryList(java.lang.Integer,
     *      java.lang.Integer, java.lang.String)
     */
    @Override
    public List<RecycleProblemSelectPojo> queryList(Integer pageSize, Integer startIndex, String order,
            Integer recyclePhoneProblemId)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("pageSize", pageSize);
        map.put("startIndex", startIndex);
        map.put("order", order);
        if (recyclePhoneProblemId != null && recyclePhoneProblemId != 0)
        {
            map.put("problemId", recyclePhoneProblemId);
        }
        return problemSelectMapper.queryList(map);
    }

    /**
     * @see com.csu.cphone.service.RecycleProblemSelectService#deleteById(java.lang.Integer)
     */
    @Override
    public Integer deleteById(Integer recycleProblemSelectId)
    {
        return problemSelectMapper.deleteById(recycleProblemSelectId);
    }

    /**
     * @see com.csu.cphone.service.RecycleProblemSelectService#add(java.lang.Integer,
     *      java.lang.String, java.lang.Integer)
     */
    @Override
    public RecycleProblemSelectPojo add(Integer problemId, String problemItem, Double cost)
    {
        RecycleProblemSelectPojo problemSelect = new RecycleProblemSelectPojo();
        problemSelect.setCost(cost);
        problemSelect.setProblemId(problemId);
        problemSelect.setProblemItem(problemItem);
        problemSelectMapper.insert(problemSelect);
        return problemSelect;
    }

}
